<%@page import="com.bean.InstrumentBean"%>
<%@page import="com.bean.MessageBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 
<head>
<head>
    <base href="<%=basePath%>">
    
    <title>instrument</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="CSS/style.css">
	<script type="text/javascript" src="JS/table.js"></script>
	
	<script type="text/javascript">
		function check(form)
		{
			var key = form.key.value;
			var value = form.value.value;
			if(key !="name" && key!="barcode")
				{alert("please select the type!"); return false;}
			if(value=="")
				{alert("please enter the content");return false;}
			if("barcode"==key && !/^\d+$/.test(value))
			{alert("number is ok!"); return false;}
			form.submit();
		}
	</script> 
	
</head>
<body bgcolor="#FFFFFF">
<%
	MessageBean message =(MessageBean)request.getAttribute("message");
	@SuppressWarnings("unchecked")
	ArrayList<InstrumentBean> insList = (ArrayList<InstrumentBean>)request.getAttribute("insList");
%>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#D1D1D1">
  <tr>
    <td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
  <tr>
    <td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="22" valign="top" class="current_addr">&nbsp;Current address：Instrument &gt;&gt; Query</td>
      </tr>
      <tr>
        <td align="center" valign="top">
        
<%
String key = "barcode";
String value ="";
if(message!=null)
{
	key = message.getKey();
	value = message.getValue();
}
%>
<form action="InstrumentQueryServlet" method="post" name="queryform" style="border: 0">  
 <table width="99%" height="48"  border="0" cellpadding="0" cellspacing="0" bgcolor="#E3F4F7">
  <tr>
    <td align="center">&nbsp;<img src="images/searchi.png" width="48" height="48"></td>
    <td>Query Criteria:
      <select name="key" id="f">
        <option value="barcode" <%if("barcode".equals(key)) {%>selected<%} %>>Barcode</option>
        <option value="name" <%if("name".equals(key)) {%>selected<%} %>>Name</option>
      </select>
      <input name="value" type="text" size="50" value="<%=value%>">
      <input name="Submit" type="button" class="btn" value = "search" onclick="return check(queryform);"></td>
  </tr>
</table>
</form>
          <%if(insList==null || insList.isEmpty()){ %>
          <table width="100%" height="30"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="36" align="center" class="record"><font color="red">No records</font></td>
            </tr>
          </table>
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
  			<tr>
   			 <td>
      		<a href="lab_admin/instrument_add.jsp" class="add">Add instrument</a> </td>
			 </tr>
		 </table>
          <%} else {%>
          <table width="100%" height="30"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="36" align="center" class="record"><font color="green">SUCCESS</font></td>
            </tr>
          </table>
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
  			<tr>
   			 <td>
      		<a href="lab_admin/instrument_add.jsp" class="add">Add instrument</a> </td>
			 </tr>
		 </table>
          <%} %>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30" background="images/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="30"><img src="images/tab_03.gif" width="12" height="30" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="46%" valign="middle">          
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><div align="center"><img src="images/tb.gif" width="16" height="16" /></div></td>
                <td width="95%" class="STYLE1"><span class="STYLE3">Instrument records </span></td>
              </tr>
            </table></td>
           
          </tr>
        </table></td>
        <td width="16"><img src="images/tab_07.gif" width="16" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="8" background="images/tab_12.gif">&nbsp;</td>
        <td>
        
        
       <div style="width:100%;height:300;overflow-x:hidden;overflow-y:auto; border: 0">
        <table width="100%" border="0" style="table-layout: fixed;" cellpadding="0" cellspacing="1" bgcolor="b5d6e6" onmouseover="changeto(event);" onmouseout="changeback(event);" onclick="clickto(event);">
          <thead>
          <tr>
          	<td width="5%" height="22" background="images/bg.gif" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1">Num</span></div></td>
            <td width="20%" height="22" background="images/bg.gif" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1">Barcode</span></div></td>
            <td width="30%" height="22" background="images/bg.gif" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1">Name</span></div></td>
            <td width="10%" height="22" background="images/bg.gif" bgcolor="#FFFFFF" class="STYLE1"><div align="center">In lab</div></td>
          	<td width="40%" height="22" background="images/bg.gif" bgcolor="#FFFFFF" class="STYLE1"><div align="center">Option</div></td>
          	
          </tr>
          </thead>
          <tbody>
 <%
 	if(insList != null && !insList.isEmpty())
 	{
 	Iterator<InstrumentBean> iter = insList.iterator();
 	int num = 0;
 	String barcode = "";
 	String name = "";
 	String ifin = "";
 	while(iter.hasNext())
 	 {
 		InstrumentBean insBean = iter.next();
 	    barcode = insBean.getBarcode();
 		name = insBean.getName();
 		ifin = insBean.getIfin();
 		num++;
 %>        
		  
          <tr> 
            <td height="20" bgcolor="#FFFFFF"><div align="center" class="STYLE1">
              <div align="center"><%=num %></div>
            </div></td>
            <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=barcode %></span></div></td>
            <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=name %></span></div></td>
            <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><%=ifin %></span></div></td>
            <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE4">
            	<img src="images/stateins.png" width="16" height="16" border="0"/><a href="StateQueryServlet?key=barcode&value=<%=barcode %>" style="text-decoration: none;">state</a>&nbsp;
            	<img src="images/details.png" width="16" height="16" border="0"/><a href="InstrumentDetailServlet?barcode=<%=barcode %>" style="text-decoration: none;">detail</a>&nbsp;
            	<img src="images/edt.gif" width="16" height="16" border="0"/><a href="InstrumentModifyServlet?barcode=<%=barcode %>&option=edit" style="text-decoration: none;">edit</a>&nbsp;
            	<img src="images/del.gif" width="16" height="16" /><a href="InstrumentDeleteServlet?barcode=<%=barcode%>&key=<%=key %>&value=<%=value %>" style="text-decoration: none;">delete</a></span></div>
            </td>
          </tr>
     <%} %>     
<%} %> 
</tbody>
        </table>
        </div>
        </td>
        <td width="8" background="images/tab_15.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  
  <tr>
  
    <td height="35" background="images/tab_19.gif">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="35"><img src="images/tab_18.gif" width="12" height="35" /></td>
        <td width="16"><img src="images/tab_20.gif" width="16" height="35" /></td>
      </tr>
    </table>
    </td>
    
  </tr>
</table>

</td>
      </tr>
    </table>
</td>
  </tr>
</table></td>
  </tr>
</table>
</body>
</html>
